<template>
  <div
    :class="{
      'form-item': true,
      'el-form-item': true,
      'is-error': errMsg,
      'is-required': required,
    }"
  >
    <label class="el-form-item__label" :style="`width: ${{ labelWidth }}px`">{{
      label
    }}</label>
    <div
      class="el-form-item__content"
      :style="`margin-left: ${{ labelWidth }}px`"
    >
      <slot></slot>
      <div class="el-form-item__error" v-show="!!errMsg">{{ errMsg }}</div>
    </div>
  </div>
</template>

<script>
export default {
  name: "formItem",
  props: {
    label: {
      type: String,
      default: "",
    },
    labelWidth: {
      type: [String, Number],
      default: "100",
    },
    errMsg: {
      type: String,
      default: "",
    },
    required: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {};
  },
};
</script>

<style lang="scss">
.form-item {
}
</style>